/**
 * Created by jiangyukun on 2016/5/23.
 */

'use strict';

app.controller('PaitentAccountController', function ($scope, iHttp, $uibModal, DTOptionsBuilder, DTColumnBuilder) {

    $scope.dtOptions = DTOptionsBuilder.newOptions()
    // .withOption('info', false)
        .withOption('lengthChange', false)
        .withOption('searching', false)
        .withOption('ajax', {dataSrc: 'data'})
        .withOption('serverSide', true)
        .withOption('serverData', getServerData);


    $scope.dtColumns = [
        DTColumnBuilder.newColumn('id').withTitle('ID').notVisible(),
        DTColumnBuilder.newColumn('username').withTitle('账号'),
        DTColumnBuilder.newColumn('changePassword').withTitle('修改密码'),
        DTColumnBuilder.newColumn('userType').withTitle('用户类型'),
        DTColumnBuilder.newColumn('createDate').withTitle('创建日期')
    ];


    $scope.changePassword = changePassword;


    function getServerData(source, data, callback) {
        iHttp.get('mock/json/patient-account.json', {data: data}).then(function (result) {
            callback(result.data);
        });
    }

    function changePassword() {
        $uibModal.open({
            templateUrl: 'tpl/account/change_password_dialog.html',
            controller: 'ChangePasswordController'
        })
    }
});

app.controller('ChangePasswordController', function ($scope, $uibModalInstance) {
    $scope.close = close;


    function close() {
        $uibModalInstance.close();
    }
});